package fivm.cross.platform.steamobj.appcase;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import fivm.cross.platform.ficommon.distinguish.FiObjectId;
import fivm.cross.platform.ficommon.distinguish.GsonSimpleSerializable;
import fivm.cross.platform.steamobj.controller.CommandStream;

/**
 * Created by Administrator on 2016/5/18.
 * app 用例交互及其控制过程的数据流
 * 属于用例业务的一个子属性
 * 保存着
 * 1、用例是否完成或者失败等状态
 * 2、服务器下发给客户端下一步要执行的内容
 *
 */
public class CaseInteractiveControlStream extends GsonSimpleSerializable {
    @Expose @SerializedName("_id")
    private FiObjectId id=FiObjectId.NewNull;
    /**
     * status：
     * 用例当前运行的状态，如未初始化、运行中、失败、完成等
     */
    public final static int STATUS_uninitialized=0;       //未初始化
    public final static int STATUS_running=1;             //运行中
    public final static int STATUS_failed=2;              //运行失败
    public final static int STATUS_finished=3;            //运行成功完成
    public final static int STATUS_startup=4;             //启动
    public final static int STATUS_task_exit=5;           //app任务退出
    public final static int STATUS_pool_empty=6;          //运行成功完成
    public final static int STATUS_timeout=7;             //用例超时
    @Expose @SerializedName("Status")
    private int status=STATUS_uninitialized;

    public final static int ACTION_STARTUP=0;             //用例启动请求
    public final static int ACTION_POLLASKING=1;          //轮询请求
    public final static int ACTION_REPORT_TIMEOUT=2;      //用例超时上报

    @Expose @SerializedName("RequestAction")
    private int requestAction=ACTION_STARTUP;


    @Expose @SerializedName("ExtraMsg")
    private String extraMsg="";                             //附加的信息
    @Expose @SerializedName("ExtraSleeptime")
    private long extraSleeptime=1000;                     //如果是要休眠，那要休眠的时间要传下去

    @Expose @SerializedName("ClientActionCommands")
    private CommandStream clientActionCommands[];    //服务器下发让客户端要执行的行为，应该是多个行为


    @Expose @SerializedName("ProxyIpInfo")
    private ProxyIpInfo proxyIpInfo;    //代理ip


    @Expose @SerializedName("DroidParams")
    private DroidParamsStream droidParams;    //一个用例应是对应一个参数

    /**
     * 生成一个新的刚启动的用例交互流
     * */
    public static CaseInteractiveControlStream generateNewStartupCaseInteractive(){
        CaseInteractiveControlStream caseInteractiveControlStream=new CaseInteractiveControlStream();
        caseInteractiveControlStream.setStatus(STATUS_uninitialized);
        //caseInteractiveControlStream.setReportAction(REPORT_ACTION_APP_startup);
        return caseInteractiveControlStream;
    }




    public CommandStream[] getClientActionCommands() {
        return clientActionCommands;
    }

    public void setClientActionCommands(CommandStream[] clientActionCommands) {
        this.clientActionCommands = clientActionCommands;
    }




    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }


    public String getExtraMsg() {
        return extraMsg;
    }

    public void setExtraMsg(String extraMsg) {
        this.extraMsg = extraMsg;
    }

    public long getExtraSleeptime() {
        return extraSleeptime;
    }

    public void setExtraSleeptime(long extraSleeptime) {
        this.extraSleeptime = extraSleeptime;
    }

    public DroidParamsStream getDroidParams() {
        return droidParams;
    }

    public void setDroidParams(DroidParamsStream droidParams) {
        this.droidParams = droidParams;
    }

    public FiObjectId getId() {
        return id;
    }

    public void setId(FiObjectId id) {
        this.id = id;
    }

    public int getRequestAction() {
        return requestAction;
    }

    public void setRequestAction(int requestAction) {
        this.requestAction = requestAction;
    }

    public ProxyIpInfo getProxyIpInfo() {
        return proxyIpInfo;
    }

    public void setProxyIpInfo(ProxyIpInfo proxyIpInfo) {
        this.proxyIpInfo = proxyIpInfo;
    }
}
